package tk.hongbo.demo.api.user;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import tk.hongbo.demo.model.UserPojo;
import tk.hongbo.demo.request.RequestOne;

@Api("这是用户部分文档")
@RestController
@RequestMapping("/api/user")
public class ApiUser {

    @ApiOperation("获取用户信息")
    @RequestMapping(value = "/getUser", method = RequestMethod.GET)
    public String getUser() {
        return "Hello, HongboZhao";
    }

    @ApiOperation("获取详细信息")
    @RequestMapping(value = "/getInfo", method = RequestMethod.GET)
    public String getInto(@RequestParam(name = "name", required = false, defaultValue = "张三") String name) {
        return "你好，" + name;
    }

    @ApiOperation("获取一个用户")
    @GetMapping("/getOne")
    public UserPojo getOne() {
        UserPojo pojo = new UserPojo();
        pojo.setUsername("猪八戒");
        pojo.setContent("吃货一枚，乐观主义");
        return pojo;
    }

    @ApiOperation("根据条件获取用户")
    @GetMapping("/getTwo")
    public UserPojo getTwo(RequestOne reques) {
        UserPojo pojo = new UserPojo();
        pojo.setUsername("张" + reques.getFilter());
        pojo.setContent("我们是祖国的花朵");
        return pojo;
    }
}